using System;
using System.ComponentModel;
using System.Configuration;

namespace Needle.Core.Configuration {
    /// <summary>
    /// Describes the injected argument.
    /// </summary>
    public class ArgumentElement : ConfigurationElement {
     
        #region constructor
        /// <summary>
        /// creates a new instance.
        /// </summary>
        public ArgumentElement() { }

        /// <summary>
        /// Creates a new instance.
        /// </summary>
        public ArgumentElement(int index, InstanceId dependency) {
            this.Index = index;
            if (dependency != null)
                Inject = dependency.ToString();
        }

        /// <summary>
        /// Creates a new instance.
        /// </summary>
        public ArgumentElement(int index,Type t, InstanceId dependency)
        {
            this.Index = index;
            if (t != null)
                this.Type = t.AssemblyQualifiedName;
            if (dependency != null)
                Inject = dependency.ToString();
        }
        
        #endregion

        /// <summary>
        /// The argument index to inject.
        /// </summary>
        [ConfigurationProperty(Element.Index, IsRequired = true)]
        [Description("The argument index to inject.")]
        public int Index
        {
            get { return (int)this[Element.Index]; }
            set { this[Element.Index] = value; }
        }

        /// <summary>
        /// the argument type. required when needed to disambiguate 
        /// injected constructors or methods with the same number of arguments
        /// </summary>
        [ConfigurationProperty(Element.Type, IsRequired = false)]
        [Description("The argument type. required when needed to disambiguate injected constructors or methods with the same number of arguments")]
        public string Type
        {
            get { return (string)this[Element.Type]; }
            set { this[Element.Type] = value; }
        }

        /// <summary>
        /// The dependency to inject.
        /// </summary>
        [ConfigurationProperty(Element.Inject, IsRequired = false)]
        [Description("The dependency to inject.")]
        public string Inject
        {
            get { return (string)this[Element.Inject]; }
            set { this[Element.Inject] = value; }
        }

        internal object GetParameter()
        {
            throw new NotImplementedException();
        }
    }
}
